<!--{subtemplate manage/header}-->
<link type="text/css" rel="stylesheet" href="./tpl/css/weebox.css" />
<script type="text/javascript" src="./tpl/js/shareutil.js"></script>
<div class="manage_edit">
	<div class="manage_title">
		<span>编辑分享：{$share['share_id']}</span>
	</div>
	<div class="manage_unlock">
		<span>当前已锁定此分享，其他管理员将不能对其进行操作，解锁请占击</span>
		<a href="javascript:;" onclick="$.UnManageLock('share',{$share['share_id']},this)">【取消锁定】</a>
		<span>，解锁后将关闭编辑页面</span>
	</div>
	<form method='post' id="form" name="form" action="{$_FANWE[site_root]}manage/manage.php" enctype="multipart/form-data" >
	<table class="table-form">
		<tr>
			<th width="100">标题</th>
			<td><input type="text" size="80" class="textinput requireinput" name="title" value="{$share['title']}" /></td>
		</tr>
		<tr>
			<th width="100">分享标签</th>
			<td><input type="text" class="textinput" name="tags" value="{$share['share_tags']}" style="width:90%">
			<div class="blank9"></div>
			用空格分隔</td>
		</tr>

		<tr>
			<th>内容</th>
			<td>
				<textarea name="content" class="pub_txt PUB_TXT" length="140" position="0">{$share['content']}</textarea>
				<input type="hidden" id="position_count" class="pub_count" value="0" />
				<div style="padding:10px 0 0 0;">
					<a w="pub" href="javascript:;" class="add_face" id="add_face" onclick="$.Show_Expression(this);">{lang face}</a>
				</div>
			</td>
		</tr>
		{if $share['share_data'] != 'default'}
		<tr>
			<th>所属分类</th>
			<td>
				<table>
				<tr>
					<td>
						<select multiple="multiple"  name="cate" style="width:260px; height:200px;">
						<!--{loop $_FANWE['cache']['goods_category']['parent'] $rootid}-->
						<!--{eval $rcate = $_FANWE['cache']['goods_category']['all'][$rootid];}-->
						<option value="{$rootid}">{$rcate['cate_name']}</option>
						<!--{loop $rcate['child'] $childid}-->
						<!--{eval $ccate = $_FANWE['cache']['goods_category']['all'][$childid];}-->
						<option value="{$childid}">&nbsp;&nbsp;|--&nbsp;{$ccate['cate_name']}</option>
						<!--{/loop}-->
						<!--{/loop}-->
						</select>
					</td>
					<td width=30 style="text-align:center;vertical-align:middle;">
						<input type="button" value=">>" name="add" class="formbutton" />
						<div class="blank9"></div>
						<input type="button" value="<<" name="remove" class="formbutton" />
					</td>
					<td>
						<select multiple="multiple"  name="share_cate" style="width:260px; height:200px;">
							<!--{loop $share_category $cate}-->
								<option value="{$cate['cate_id']}">{$cate['cate_name']}</option>
							<!--{/loop}-->
						</select>
					</td>
				</tr>
				</table>
				
			</td>
		</tr>
		{/if}
		<tr class="act">
			<th>&nbsp;</th>
			<td>
				<input type="hidden" name="share_id" value="{$share['share_id']}" />
				<input type="hidden" name="share_cates" value="{eval $idx = 1;}<!--{loop $share_category $cate}-->{if $idx <>1},{/if}{$cate['cate_id']}{eval $idx ++ ;}<!--{/loop}-->" />
				<input type="hidden" name="m" value="share" />
				<input type="hidden" name="a" value="update" />
				<input type="submit" class="formbutton" value="提交" />
				<input type="reset" class="formbutton" value="重置" />
			</td>
		</tr>
	</table>
	</form>
</div>
<script type="text/javascript">
<!--{if $share['share_data'] != 'default'}-->
$(document).ready(function(){
	$("select[name='cate']").bind("dblclick",function(){
		add_cate();
	});
	$("input[name='add']").bind("click",function(){
		add_cate();
	});
	$("select[name='share_cate']").bind("dblclick",function(){
		remove_cate();
	});
	$("input[name='remove']").bind("click",function(){
		remove_cate();
	});
});

function add_cate()
{
	var select_option = $("select[name='cate']").find("option:selected");
	var exist_option = $("select[name='share_cate']").find("option");
	var obj = new Array();
	for(i=0;i<select_option.length;i++)
	{
		is_add = true;
		for (j = 0; j < exist_option.length; j++) 
		{
			if ($(select_option[i]).attr("value") == $(exist_option[j]).attr("value")) 
			{
				is_add = false;
				break;
			}
		}
		if(is_add)
		{
			obj.push(select_option[i]);
		}
	}
	var clone = $(obj).clone();
	$("select[name='share_cate']").append(clone);
	
	var text = $("select[name='share_cate']").html().replace(/&nbsp;/g,'');
	text = text.replace(/\|--/g,'');
	$("select[name='share_cate']").html(text);
	
	var opts = $("select[name='share_cate']").find("option");
	var ids = new Array();
	for(i=0;i<opts.length;i++)
	{
		ids.push($(opts[i]).attr("value"));
	}
	$("input[name='share_cates']").val(ids.join(","));
}

function remove_cate()
{
	$("select[name='share_cate']").find("option:selected").remove();	
	var opts = $("select[name='share_cate']").find("option");
	var ids = new Array();
	for(i=0;i<opts.length;i++)
	{
		ids.push($(opts[i]).attr("value"));
	}
	$("input[name='share_cates']").val(ids.join(","));
}
<!--{/if}-->
</script>
<!--{subtemplate manage/footer}-->
